package com.ava.avamedia.adapter;

import java.util.ArrayList;

import com.ava.avamedia.R;
import com.ava.avamedia.model.Account;
import com.ava.avamedia.model.Profile;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


public class AccountAdapter extends BaseAdapter {
	Context ctx;
	ArrayList<Account> listAccount;
	LayoutInflater mInflater;
	public AccountAdapter(Context ctx, ArrayList<Account> lstAccount) {
		super();
		this.ctx = ctx;
		this.listAccount = lstAccount;
		mInflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return listAccount.size();
	}

	public Object getItem(int arg0) {
		return listAccount.get(arg0);
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	public View getView(int arg0, View arg1, ViewGroup arg2) {
		if (arg1 == null) {
			arg1 = mInflater.inflate(R.layout.adapter_account, null);
		}
		Account account = (Account) getItem(arg0);
		TextView txtTitle = (TextView) arg1.findViewById(R.id.adapter_account_txt_title);
		TextView txtDesc = (TextView) arg1.findViewById(R.id.adapter_account_txt_desc);
		ImageView imageView= (ImageView) arg1.findViewById(R.id.adapter_account_image_view);
		if (account.isShowImage) {
			imageView.setVisibility(View.VISIBLE);
		}
		txtTitle.setText(account.title);
		if (account.desc.equals("")) {
			txtDesc.setVisibility(View.GONE);
		}
		txtDesc.setText(account.desc);
		return arg1;
	}
}
